home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD v2.1 / Amiga Developer CD v2.1.iso / CDTV / cdtvtools-11 / debug / examples / mydebug.h < prev    next >
C/C++ Source or Header  |  1991-06-21  |  2KB  |  94 lines

  1. /*
  2.  * mydebug.h - #include this file sometime after stdio.h
  3.  * Set MYDEBUG to 1 to turn on debugging, 0 to turn off debugging
  4.  */
  5. #ifndef MYDEBUG_H
  6. #define MYDEBUG_H
  7.  
  8. #define MYDEBUG     1
  9.  
  10. #if MYDEBUG
  11. /*
  12.  * MYDEBUG User Options
  13.  */
  14.  
  15. /* Set to 1 to turn second level D2(bug()) statements */
  16. #define DEBUGLEVEL2    1
  17.  
  18. /* Set to a non-zero # of ticks if a delay is wanted after each debug message */
  19. #define DEBTIME        0
  20.  
  21. /* Set to 1 for serial debugging (link with debug.lib) */
  22. #define KDEBUG        0
  23.  
  24. /* Set to 1 for parallel debugging (link with ddebug.lib) */
  25. #define DDEBUG        0
  26.  
  27. #endif /* MYDEBUG */
  28.  
  29.  
  30. /* Prototypes for Delay, kprintf, dprintf. Or use proto/dos.h or functions.h. */
  31. #include <clib/dos_protos.h>
  32. void kprintf(UBYTE *fmt,...);
  33. void dprintf(UBYTE *fmt,...);
  34.  
  35. /*
  36.  * D(bug()), D2(bug()), DQ((bug()) only generate code if MYDEBUG is non-zero
  37.  *
  38.  * Use D(bug()) for general debugging, D2(bug()) for extra debugging that you
  39.  * usually won't need to see, DQ(bug()) for debugging that you'll never want
  40.  * a delay after (ie. debugging inside a Forbid, Disable, Task, or Interrupt)
  41.  *
  42.  * Some example uses:
  43.  * D(bug("about to do xyz. variable = $%lx\n",myvariable)); 
  44.  * D2(bug("v1=$%lx v2=$%lx v3=$%lx\n",v1,v2,v3)); 
  45.  * DQ(bug("in subtask: variable = $%lx\n",myvariable));
  46.  *
  47.  * Set MYDEBUG above to 1 when debugging is desired and recompile the modules
  48.  *  you wish to debug.  Set to 0 and recompile to turn off debugging.
  49.  *
  50.  * User options set above:
  51.  * Set DEBUGDELAY to a non-zero # of ticks (ex. 50) when a delay is desired.
  52.  * Set DEBUGLEVEL2 nonzero to turn on second level (D2) debugging statements
  53.  * Set KDEBUG to 1 and link with debug.lib for serial debugging.
  54.  * Set DDEBUG to 1 and link with ddebug.lib for parallel debugging.
  55.  */
  56.  
  57.  
  58.  
  59. /* 
  60.  * Debugging function automaticaly set to printf, kprintf, or dprintf
  61.  */
  62.  
  63. #if KDEBUG
  64. #define bug kprintf
  65. #elif DDEBUG
  66. #define bug dprintf
  67. #else    /* else changes all bug's to printf's */
  68. #define bug printf
  69. #endif
  70.  
  71.  
  72. /*
  73.  * Debugging macros
  74.  */
  75.  
  76. /* DQ (debug quick) never uses Delay.  Use in forbids,disables,tasks,interrupts */
  77. #if MYDEBUG
  78. #define D(x) (x); if(DEBTIME>0) Delay(DEBTIME)
  79. #define DQ(x) (x)
  80. #if DEBUGLEVEL2
  81. #define D2(x) (x); if(DEBTIME>0) Delay(DEBTIME)
  82. #else
  83. #define D2(x) ;
  84. #endif /* DEBUGLEVEL2 */
  85. #else
  86. #define D(x) ;
  87. #define DQ(x) ;
  88. #define D2(x) ;
  89. #endif
  90.  
  91.  
  92. #endif /* MYDEBUG_H */
  93.  
  94.